using System;
using System.Drawing;
using UIKit;

namespace Babel.Ios
{
	public class MyViewController : UIViewController
	{
		private UIButton button;
		private int numClicks = 0;
		private float buttonWidth = 200;
		private float buttonHeight = 50;

		public MyViewController ()
		{
		}

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			View.Frame = UIScreen.MainScreen.Bounds;
			View.BackgroundColor = UIColor.White;
			View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

			button = UIButton.FromType (UIButtonType.RoundedRect);

			button.Frame = new RectangleF (
				(float)View.Frame.Width / 2 - buttonWidth / 2,
				(float)View.Frame.Height / 2 - buttonHeight / 2,
				(float)buttonWidth,
				(float)buttonHeight);

			button.SetTitle ("Click me", UIControlState.Normal);

			button.TouchUpInside += (object sender, EventArgs e) => {
				button.SetTitle (String.Format ("clicked {0} times", numClicks++), UIControlState.Normal);
			};

			button.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin |
			UIViewAutoresizing.FlexibleBottomMargin;

			View.AddSubview (button);
		}
	}
}